package org.datastealer.bean;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/**
 * Note：
 *
 * @author ：mengjw
 * @description：自定义sql执行结果
 * @date ：Created in 2020/9/22
 */
@Data
@Builder
public class CustomSqlResult implements Serializable {

    private static final long serialVersionUID = -6360128052162221970L;
    /**
     * 结果类型
     */
    String resultType;
    /**
     * 结果
     */
    Object result;
    /**
     * 执行时间，ms
     */
    long executeTime;

    public static CustomSqlResult getBooleanResult(long executeTime) {
        return CustomSqlResult.builder().resultType("boolean")
                .result("执行成功！")
                .executeTime(executeTime).build();
    }

    public static CustomSqlResult getAffectResult(int affectRows, long executeTime) {
        return CustomSqlResult.builder().resultType("affect")
                .result("执行成功，共影响" + affectRows + "行！")
                .executeTime(executeTime).build();
    }

    public static CustomSqlResult getDataResult(Object data, long executeTime) {
        return CustomSqlResult.builder().resultType("data")
                .result(data)
                .executeTime(executeTime).build();
    }
}